/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable no-unneeded-ternary */
import React, { Component } from 'react';
import moment from 'moment';
import Link from 'umi/link';
import StandardTable from '@/components/StandardTable';
import styles from './index.less';
import TextOverFlow from './TextOverFlow';

class BaseInfor extends Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  componentDidMount() {}

  render() {
    const {
      isProObj,
      proUrl,
      timeFlag,
      columns = [
        { title: '姓名', dataIndex: 'empName', render: text => text || '--' },
        {
          title: '证件号',
          dataIndex: 'certId',
          onCell: () => ({
            style: {
              textAlign: 'center',
            },
          }),
          onHeaderCell: () => ({
            style: {
              textAlign: 'center',
              fontWeight: 'bold',
              width: 170,
            },
          }),
          render: text => text || '--',
        },
        { title: '客户名称', dataIndex: 'custName', render: text => <TextOverFlow text={text} /> },
        { title: '问题对象', dataIndex: 'probObj', className: isProObj ? null : styles.hide },
        { title: '问题类型', dataIndex: 'probTypeIdName', render: text => text || '--' },
        {
          title: '提出时间',
          dataIndex: 'creTime',
          sorter: timeFlag ? true : false,
          render: text => moment(text).format('YYYY-MM-DD HH:mm'),
        },
        {
          title: '所属客服',
          dataIndex: 'blngCs',
          render: text => text || '--',
        },
        {
          title: '操作',
          dataIndex: 'n11',
          onHeaderCell: () => ({ style: { width: 80 } }),
          render: (text, record) => (
            <div>
              <Link to={`${proUrl}?detId=${record.detId}`}>查看</Link>
            </div>
          ),
        },
      ],
    } = this.props;
    return (
      <div>
        <StandardTable {...this.props} columns={columns} />
      </div>
    );
  }
}

export default BaseInfor;
